﻿//===============================================================================
// Microsoft patterns & practices Enterprise Library Contribution
// Logging Application Block
//===============================================================================

using System;
using System.Configuration;
using System.Diagnostics;
using System.Windows.Forms;
using Microsoft.Practices.EnterpriseLibrary.Common.Configuration;
using Microsoft.Practices.EnterpriseLibrary.Configuration.Design;
using EntLibContrib.Logging.Properties;

namespace EntLibContrib.Logging.Configuration.Design
{
	/// <summary>
	/// Represents the design manager for the exception handling settings configuration section.
	/// </summary>
	public sealed class LoggingConfigurationDesignManager : ConfigurationDesignManager
	{
		/// <summary>
		/// Initialize a new instance of the <see cref="LoggingConfigurationDesignManager"/> class.
		/// </summary>
		public LoggingConfigurationDesignManager()
		{
		}

		/// <summary>
		/// Register the commands and node maps needed for the design manager into the design time.
		/// </summary>
		/// <param name="serviceProvider">The a mechanism for retrieving a service object; that is, an object that provides custom support to other objects.</param>
		public override void Register(IServiceProvider serviceProvider)
		{
			LoggingCommandRegistrar cmdRegistrar = new LoggingCommandRegistrar(serviceProvider);
			cmdRegistrar.Register();
			LoggingNodeMapRegistrar registrar = new LoggingNodeMapRegistrar(serviceProvider);
			registrar.Register();
		}

		/// <summary>
		/// Opens the logging settings configuration section, builds the design time nodes and adds them to the application node.
		/// </summary>
		/// <param name="serviceProvider">The a mechanism for retrieving a service object; that is, an object that provides custom support to other objects.</param>
		/// <param name="rootNode">The root node of the application.</param>
		/// <param name="section">The <see cref="ConfigurationSection"/> that was opened from the <see cref="IConfigurationSource"/>.</param>
		protected override void OpenCore(IServiceProvider serviceProvider, ConfigurationApplicationNode rootNode, ConfigurationSection section)
		{
			base.OpenCore(serviceProvider, rootNode, section);
		}
	}
}
